package com.ny.zuoye2567.dao.dao;

import com.ny.zuoye2567.dao.DbUntil;
import com.ny.zuoye2567.dao.shiti.Order;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.List;

public class OrderDaoImpl implements OderDao{
    private  DbUntil dbUntil = new DbUntil() ;


    @Override
    public int insertOrder(Order order) throws SQLException, ClassNotFoundException {
        Connection connection = dbUntil.getCon();
        String sql = "insert into orders(student_Id,product_Id,number,total_price) values(?,?,?,?)";
        PreparedStatement preparedStatement = connection.prepareStatement(sql);
        preparedStatement.setInt(1,order.getStudentId());
        preparedStatement.setInt(2,order.getProductId());
        preparedStatement.setInt(3,order.getNumber());
        preparedStatement.setDouble(4,order.getPrice());
        return preparedStatement.executeUpdate();
    }

    @Override
    public List<Order> findAllOrders() {
        return null;
    }

    @Override
    public int deleteOrderByStudentName(String studentName) {
        return 0;
    }
}
